package com.cjlgb.design.common.security.cfgbean;

import com.cjlgb.design.common.security.handler.InnerRequestAspectHandler;
import com.cjlgb.design.common.security.handler.PermissionHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.servlet.http.HttpServletRequest;

/**
 * @author WFT
 * @date 2019/7/15
 * description: 权限相关配置
 */
@Slf4j
@Configuration
@RequiredArgsConstructor
public class SecurityConfiguration {

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean(value = "pms")
    public PermissionHandler securityCheckHandler(){
        return new PermissionHandler();
    }

    @Bean
    public InnerRequestAspectHandler innerRequestAspectHandler(@Autowired HttpServletRequest request){
        return new InnerRequestAspectHandler(request);
    }

}
